package com.wsj.neo4j.simple.controller;

import com.wsj.neo4j.simple.entity.Person;
import com.wsj.neo4j.simple.repository.PersonRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author WangSongJun
 * @date 2019-10-28
 */
@RestController
@RequestMapping("person")
public class PersonController {
    @Autowired
    private PersonRepository personRepository;

    @GetMapping("add")
    public Person add() {
        String timeMillis = String.valueOf(System.currentTimeMillis());
        Person person = Person.builder().name(timeMillis.substring(timeMillis.length() - 3)).phone(timeMillis).build();

        Person save = personRepository.save(person);

        return save;
    }
}
